<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "change_table_log".
 *
 * @property integer $id
 * @property string $table_name
 * @property integer $uid
 * @property string $action
 * @property string $content
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $row_id
 */
class ChangeTableLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'change_table_log';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['table_name', 'action', 'content'], 'required'],
            [['uid', 'created_at', 'updated_at', 'row_id'], 'integer'],
            [['content'], 'string'],
            [['table_name'], 'string', 'max' => 20],
            [['action'], 'string', 'max' => 100],
        ];
    }

    public function beforeSave($insert)
    {
        if($insert){
            $this->created_at = time();
        }
        $this->updated_at = time();
        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'table_name' => 'Table Name',
            'uid' => 'Uid',
            'action' => 'Action',
            'content' => 'Content',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }
}
